package com.atguigu.lease.common.minio;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by 小可乐$ on 2024/8/13$ 9:00$
 * description: minio的配置类
 */
@Configuration
//方式一：注册minio实体类映射
@EnableConfigurationProperties(MinioProperties.class)
//方式二：注册minio实体类扫描映射
//@ConfigurationPropertiesScan("com.atguigu.lease.common.minio")
public class MinioConfiguration {
    @Autowired
    private MinioProperties properties;

    @Bean
    public MinioClient minioClient() {
//        构建minio连接
        MinioClient minioClient = MinioClient.builder()
                .endpoint(properties.getEndpoint())
                .credentials(properties.getAccessKey(), properties.getSecretKey())
                .build();

        return minioClient;

    }
}
